<?php
class DefaultSitemapAction extends FrontendAction
{
	public function __construct()
	{
		parent::__construct();
		$this->responseType = 'tpl';
		$this->layout = 'index';
	}

	public function execute()
	{
		$page			= $this->getPage();
		
		//第一页显示帮助列表
		if($page==1)
		{
			$helpService	= new HelpService();
			$tmp			= $helpService->getAll('id,title');
			if(!empty($tmp))
			{
				$this->data['helpList']	= $tmp['rows'];
			}
		}
		
		$ltConfig		= C('LtConfig');
		$pagerConfig	= $ltConfig->get('pagination.pager');
		$pageSize		= 100;
		$pagerConfig['per_page']		= $pageSize;

		$pagerConfig['num_links_show']	= 20;

		$ltConfig->addConfig(array('pagination.pager'=>$pagerConfig));
		
		$num 			= $pageSize;
		$start	 		= ($page-1) * $pageSize;
		
		$categoryService			= new CategoryService();
		$categoryList				= $categoryService->getSitemapCategoryList($start,$num);
		$this->data['categoryList']	= $categoryList['rows'];
		$totalNum					= $categoryList['count'];
		
		$baseUrl 	= C('LtUrl')->generate('Default', 'Sitemap', array('p' => ':page'));
		
		$pagination 	= new PiscesPagination;
		$pagination->init();
		$this->data['pages'] = $pagination->pager($page, $totalNum, $baseUrl);
		
		$this->data['seo']['title']	= '网站地图-'.$page;
	}
}
